<html>
<head>
<link rel='stylesheet' href='../view/css/bootstrap.css' />
</head>
<body>
<?php 
$host='localhost';
$user='root';
$pass='';
$conn=@mysql_connect($host,$user,$pass);
	if($conn){
		//echo "<span class='alert alert-success'>Connection has been Established Successfully</span> | Link Value=" . $conn;
		//$db=mysql_query("USE fb");
		$db=mysql_select_db('fb');
		/*if($db){
			echo "<div>Database Selected</div>";
		}
		else{
			echo "<div>Unable to Select Database Or Database Not Exists</div>";
		}*/
		$text=$_POST['add_update'];
		if($text== '' || $text==null){
			echo "<p class='alert alert-error'>This is required to enter a text</p>";
			
		}
		else{
			//echo "Thanks, you submited a text";
			$insert=mysql_query("INSERT INTO updates (id,post) VALUES (null,'$text')");
			if($insert){
				//echo "<p class='alert alert-success'>Thank you for Posting</p>";
				echo "<meta http-equiv='refresh' content='2;URL=../view/index.php'>";
			}
			else{
				echo "<p class='alert alert-error'>Ooops Error Occured!</p>" . mysql_error();
			}
		}
	}
	else{
		echo "<div class='alert alert-error'>Connection Refuse<br/>" . mysql_error() . "</div>";	
	}
?>
</body>
</html>